package com.yjetms.service;

import com.yjetms.entity.User;
import com.yjetms.entity.UserDao;
import com.yjetms.entity.UserDaoImpl;
import com.yjetms.repository.UserRepository;

public class UserServiceImpl implements UserService{

    UserDao ud;

    public UserServiceImpl(UserRepository userRepository){
        ud = new UserDaoImpl(userRepository);
    }

    @Override
    public void registUser(User user) {
        ud.saveUser(user);
    }

    @Override
    public User Login(User user) {
        return ud.queryUserByUseernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existUserName(String username) {
        User user = ud.queryUserByUsername(username);
        return user != null;
    }
}
